package com.custom.base.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.custom.base.R
import com.custom.base.base.BaseAdapter
import com.custom.base.drawable.SDDrawableManager
import com.custom.base.manager.SDActivityManager
import com.custom.base.util.SDViewUtil.setBackgroundDrawable

class SDSimpleTextAdapter<T>(
    listModel: MutableList<T>,
    var color:List<Int> = listOf()
) : BaseAdapter<T>(listModel,SDActivityManager.instance.lastActivity) {
    private val mdDrawableManager = SDDrawableManager()
    override fun getLayoutId(position: Int, convertView: View?, parent: ViewGroup?): Int {
        return R.layout.item_simple_text
    }

    override fun bindData(
        position: Int,
        convertView: View?,
        parent: ViewGroup?,
        model: T
    ) {
        convertView?.apply {
            setBackgroundDrawable(this, mdDrawableManager.getSelectorWhiteGray(false))
            val tvName = find<TextView>(R.id.item_simple_text_tv_name, convertView)
            if (color.isNotEmpty()) {
                tvName.setTextColor(color[position])
            }
            tvName.text = model.toString()
        }
    }
}